package com.concurrency.practise.service;

import com.concurrency.practise.entity.Dog;
import com.concurrency.practise.entity.repository.DogRepository;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @program: currency_practise
 * @description:
 * @author: Jiliang.Lee
 * @create: 2019-12-12 11:00
 **/
@Service
@AllArgsConstructor
@Slf4j
@CacheConfig(cacheNames = "cache0")
public class DogQueryService {
	private final DogRepository dogRepository;

	@Cacheable(key = "#id")
	public Dog getDog(Long id) {
		log.info("查库了...");
		return dogRepository.findById(id).get();
	}
}
